import { computed, ref } from 'vue';
import { ACTION_TYPE } from '@/schema/schema-table';
import { tableSchemas } from './schema';

export function useTableState({

  openFormModal,
  openRemoveConfirm,
}) {

  const getColumns = computed(() => {
    return [
      ...tableSchemas,
      {
        title: '操作',
        dataIndex: 'operation',
        key: 'operation',
        fixed: 'right',
        width: 140,
        align: 'center',
        actions: ({ record }: any) => [
          {
            label: '编辑',
            class: 'edit-btn',
            icon: 'icon-editor',
            type: "link", size: "small",
            onClick: () => {
              openFormModal(record);
            },
          },
          {
            class: 'delete-btn',
            label: '删除',
            icon: 'icon-delete_1',
            type: "link", size: "small",
            onClick: () => {
              openRemoveConfirm(record.id);
            },
          },
        ],
      },
    ];
  });

  return {
    getColumns,
  };
}
